﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "RadioButtonGroupDefinitionReference.h"
#include "ControlDefinitionChangeEvent.h"
#include "IRadioButtonGroupHandler.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

namespace gcmp
{
RadioButtonGroupDefinitionReference::RadioButtonGroupDefinitionReference(RadioButtonGroupDefinition* pRadioButtonGroupDefinition)
    :m_pControlDefinition(pRadioButtonGroupDefinition)
{
}

RadioButtonGroupDefinitionReference::~RadioButtonGroupDefinitionReference()
{

}

std::wstring RadioButtonGroupDefinitionReference::GetId() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pCheckBoxGroupDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetId();
}

std::wstring RadioButtonGroupDefinitionReference::GetCaption() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetCaption();
}

std::wstring RadioButtonGroupDefinitionReference::GetTooltip() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetTooltip();
}

bool RadioButtonGroupDefinitionReference::AddRadioButton(const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->AddRadioButton(id, caption, tooltip);
}

bool RadioButtonGroupDefinitionReference::InsertRadioButton(const std::wstring& beforeId, const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->InsertRadioButton(beforeId, id, caption, tooltip);
}

bool RadioButtonGroupDefinitionReference::DeleteRadioButton(const std::wstring& id)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->DeleteRadioButton(id);
}

void RadioButtonGroupDefinitionReference::DeleteAllRadioButtons()
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->DeleteAllRadioButtons();
}

std::vector<const IRadioButtonDefinition*> RadioButtonGroupDefinitionReference::GetAllRadioButtons() const
{
    std::vector<const IRadioButtonDefinition*> res;
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, res, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetAllRadioButtons();
}

std::wstring RadioButtonGroupDefinitionReference::GetCurrentRadioButton() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetCurrentRadioButton();
}

bool RadioButtonGroupDefinitionReference::SetCurrentRadioButton(const std::wstring& id)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetCurrentRadioButton(id);
}

gcmp::IRadioButtonGroupEvent* RadioButtonGroupDefinitionReference::GetEvent() const
{
    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetEvent();
}

bool RadioButtonGroupDefinitionReference::IsVisible() const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->IsVisible();
}

bool RadioButtonGroupDefinitionReference::IsEnabled() const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->IsEnabled();
}

bool RadioButtonGroupDefinitionReference::SetEnabled(const std::wstring& id, bool enabled)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetEnabled(id, enabled);
}

bool RadioButtonGroupDefinitionReference::SetVisible(const std::wstring& id, bool visible)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetVisible(id, visible);
}

bool RadioButtonGroupDefinitionReference::SetControlHandler(OwnerPtr<IRadioButtonGroupHandler> pControlHandler)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetControlHandler(TransferOwnership(pControlHandler));
}

bool RadioButtonGroupDefinitionReference::BlockControlHandler(bool needBlock)
{
    return m_pControlDefinition->BlockControlHandler(needBlock);
}

gcmp::IControlDefinitionChangeEvent* RadioButtonGroupDefinitionReference::GetControlDefinitionChangeEvent() const
{
    if (m_pControlDefinition)
    {
        return m_pControlDefinition->GetControlDefinitionChangeEvent();
    }
    return nullptr;
}
}// end namespace gcmp
